import axios from 'axios'
import config from './config'
import * as url from './url'
/*
 增 put     => { } // {data:Json.stringify(xx) }
 删 delete  => data:{xx:xxxx}
 改 post    => { } //(data) -->data={1:'',2:''}
 查 get     => params:{xx:xxxx}
 */


export const Status = {
    codeStatus(response){
        /*if(response.data.rsp_head.rsp_code==302){  //重定向
            window.location.href=''
        }else {
            return response.data
        }*/
      return response.data


    }
};

export const Header={'Content-Type':'application/json'};

export const CouponApi={
    getCoupons(param,config){ return axios.post(url.coupons, param, config).then(response =>{return Status.codeStatus(response)}).catch(error=>{console.log(error)})},
    getCouponList (param){return axios.get(url.couponList, param, config).then(response =>{return Status.codeStatus(response)}).catch(error=>{console.log(error)})},
    getCouponDetail (param){return axios.get(url.couponDetail, param, config).then(response =>{return Status.codeStatus(response)}).catch(error=>{console.log(error)})},
    getCouponOff(param,config){return axios.post(url.couponOff, param, config).then(response =>{return Status.codeStatus(response)}).catch(error=>{console.log(error)})},
    delCoupons($url,param){return axios.delete($url, param, config).then(response =>{return Status.codeStatus(response)}).catch(error=>{console.log(error)})},



};
export const MessageApi={
    getMessage (param){ return axios.get(url.message, param, config).then(response =>{return Status.codeStatus(response)}).catch(error=>{console.log(error)})},
    postMessage(param,config){ return axios.post(url.message, param, config).then(response =>{return Status.codeStatus(response)}).catch(error=>{console.log(error)})},
    putMessage ($url,param){ return axios.put($url, param, config).then(response =>{return Status.codeStatus(response)}).catch(error=>{console.log(error)})},
    delMessage($url,param) { return axios.delete($url, param, config).then(response =>{return Status.codeStatus(response)}).catch(error=>{console.log(error)})},

};

